package com.forum.pojo;
// default package

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;


/**
 * Post entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="t_post"
    ,catalog="forum"
)

public class Post  implements java.io.Serializable {


    // Fields    

     private Integer postid;
     private Subitem subitem;
     private User user;
     private Integer replynum;
     private String emotion;
     private String headline;
     private String content;
     private String posttime;
     private Integer clicknum;
     private Set<Reply> replies = new HashSet<Reply>(0);


    // Constructors

    /** default constructor */
    public Post() {
    }

	/** minimal constructor */
    public Post(Subitem subitem, User user, String headline, String content, String posttime) {
        this.subitem = subitem;
        this.user = user;
        this.headline = headline;
        this.content = content;
        this.posttime = posttime;
    }
    
    /** full constructor */
    public Post(Subitem subitem, User user, Integer replynum, String emotion, String headline, String content, String posttime, Integer clicknum, Set<Reply> replies) {
        this.subitem = subitem;
        this.user = user;
        this.replynum = replynum;
        this.emotion = emotion;
        this.headline = headline;
        this.content = content;
        this.posttime = posttime;
        this.clicknum = clicknum;
        this.replies = replies;
    }

   
    // Property accessors
    @GenericGenerator(name="generator", strategy="increment")@Id @GeneratedValue(generator="generator")
    
    @Column(name="postid", unique=true, nullable=false)

    public Integer getPostid() {
        return this.postid;
    }
    
    public void setPostid(Integer postid) {
        this.postid = postid;
    }
	@ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="item", nullable=false)

    public Subitem getSubitem() {
        return this.subitem;
    }
    
    public void setSubitem(Subitem subitem) {
        this.subitem = subitem;
    }
	@ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="writer", nullable=false)

    public User getUser() {
        return this.user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
    
    @Column(name="replynum")

    public Integer getReplynum() {
        return this.replynum;
    }
    
    public void setReplynum(Integer replynum) {
        this.replynum = replynum;
    }
    
    @Column(name="emotion", length=31)

    public String getEmotion() {
        return this.emotion;
    }
    
    public void setEmotion(String emotion) {
        this.emotion = emotion;
    }
    
    @Column(name="headline", nullable=false, length=51)

    public String getHeadline() {
        return this.headline;
    }
    
    public void setHeadline(String headline) {
        this.headline = headline;
    }
    
    @Column(name="content", nullable=false, length=65535)

    public String getContent() {
        return this.content;
    }
    
    public void setContent(String content) {
        this.content = content;
    }
    
    @Column(name="posttime", nullable=false, length=31)

    public String getPosttime() {
        return this.posttime;
    }
    
    public void setPosttime(String posttime) {
        this.posttime = posttime;
    }
    
    @Column(name="clicknum")

    public Integer getClicknum() {
        return this.clicknum;
    }
    
    public void setClicknum(Integer clicknum) {
        this.clicknum = clicknum;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="post")

    public Set<Reply> getReplies() {
        return this.replies;
    }
    
    public void setReplies(Set<Reply> replies) {
        this.replies = replies;
    }
   








}